package com.ingrid.javi.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.ingrid.javi.R;
import com.ingrid.javi.R.id;
import com.ingrid.javi.R.layout;
import com.ingrid.javi.model.DAO;
import com.ingrid.javi.model.Movie;

public class DetailsWishActivity extends Activity {

	public static final String EXTRA_SELECTED_ID = "extraSelectedPosition";
	private long wishId;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.wish_detail);
		this.wishId = this.getIntent().getLongExtra(EXTRA_SELECTED_ID, -1);

		Movie movie = new DAO(this).getWishMovieId(wishId);
		this.showWishMovie(movie);
	}

	private void showWishMovie(Movie movie) {
		TextView tvTitulo = (TextView) this.findViewById(R.id.tvTitulo);
		TextView tvAno = (TextView) this.findViewById(R.id.tvAno);
		TextView tvSinopse = (TextView) this.findViewById(R.id.tvSinopse);
		Button btNota = (Button) this.findViewById(R.id.btNota);

		tvTitulo.setText(movie.getTitulo());
		tvAno.setText("Ano: " + movie.getAno());
		tvSinopse.setText("Sinopse: " + movie.getSinopse());
		btNota.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				onNotaClick(wishId);
			}
		});
	}

	private void onNotaClick(long wishId) {
		Intent intent = new Intent(this, ColocaNotaActivity.class);
		intent.putExtra(ColocaNotaActivity.EXTRA_SELECTED_ID, wishId);
		this.startActivity(intent);
	}

}
